package com.cloud.pole.weixin.util.wxpay;

import java.io.FileInputStream;
import java.io.InputStream;
import org.springframework.util.ResourceUtils;
import com.cloud.pole.weixin.util.wxpay.sdk.IWXPayDomain;
import com.cloud.pole.weixin.util.wxpay.sdk.WXPayConfig;


public class WxRyConfig extends WXPayConfig{
	private static WxRyConfig wxRyConfig;
	private static String appID;
	private static String mchID;
	private static String key;
	private static IWXPayDomain iWXPayDomain;
	private String realPath;
	
	static {
		iWXPayDomain = new WxRyDomain("api.mch.weixin.qq.com",true);
		
		
	}
	public static WxRyConfig getInstance(){
		if(wxRyConfig == null){
			wxRyConfig = new WxRyConfig();
		}
		return wxRyConfig;
	}
	@Override
	public String getAppID() {
		return appID;
	}

	@Override
	public String getMchID() {
		return mchID;
	}

	@Override
	public String getKey() {
		return key;
	}

	@Override
	public InputStream getCertStream() {
		try{
			//realPath = ResourceUtils.getFile("classpath:test.txt");
			//System.out.println("realPath:" + realPath);
			//InputStream certInputStream = new FileInputStream(new File(realPath+ "apiclient_cert.p12"));
			InputStream certInputStream = new FileInputStream(ResourceUtils.getFile("classpath:apiclient_cert.p12"));
			return certInputStream;
		}catch(Exception e){
			e.printStackTrace();
		}
		return null;
		
	}

	@Override
	public IWXPayDomain getWXPayDomain() {
		return iWXPayDomain;
	}

}
